﻿<navigation:PageView x:Class="Corina.Cydee.Apphub.Views.Bases.ProvinceView"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:be="clr-namespace:Corina.Interactivity.Silverlight;assembly=Corina.Interactivity.Silverlight"
                     xmlns:controls="clr-namespace:Corina.Controls.Silverlight;assembly=Corina.Controls.Silverlight"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
                     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                     xmlns:localViewmodel="clr-namespace:Corina.Cydee.Apphub.Viewmodels"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:navigation="clr-namespace:Corina.Cydee.Apphub.Base"
                     xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                     Title="省份"
                     FontSize="14"
                     d:DesignHeight="480"
                     d:DesignWidth="640"
                     mc:Ignorable="d">
    <navigation:PageView.DataContext>
        <localViewmodel:ProvinceViewmodel />
    </navigation:PageView.DataContext>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="12" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock VerticalAlignment="Center"
                               Style="{StaticResource ControlLabelStyle}"
                               Text="关键字：" />
                    <TextBox Grid.Column="1" Text="{Binding Keywords, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                        <i:Interaction.Triggers>
                            <be:TextBoxEnterKeyTrigger>
                                <be:ExecuteCommandAction Command="{Binding LoadCommand}" />
                            </be:TextBoxEnterKeyTrigger>
                        </i:Interaction.Triggers>
                    </TextBox>
                    <Button Grid.Column="3"
                            Width="60"
                            Command="{Binding InsertCommand}"
                            Content="新增" />
                </Grid>
                <toolkit:BusyIndicator Grid.Row="1"
                                       BusyContent="{StaticResource IDS_BUSYCONTENT_LOADING}"
                                       IsBusy="{Binding IsBusy}">
                    <ListBox Margin="0,12,0,0"
                             ItemsSource="{Binding ItemsCollection}"
                             SelectedItem="{Binding SelectedProvince,
                                                    Mode=TwoWay}">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <Grid>
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="SelectionStates" ei:ExtendedVisualStateManager.UseFluidLayout="True">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="0:0:0.2" />
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="SelectedUnfocused">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0"
                                                                                 Storyboard.TargetName="grid"
                                                                                 Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                                 To="1"
                                                                                 d:IsOptimized="True" />
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="stackpanel" Storyboard.TargetProperty="(UIElement.Visibility)">
                                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                                        <DiscreteObjectKeyFrame.Value>
                                                                            <Visibility>Visible</Visibility>
                                                                        </DiscreteObjectKeyFrame.Value>
                                                                    </DiscreteObjectKeyFrame>
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Unselected" />
                                                        <VisualState x:Name="Selected">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0"
                                                                                 Storyboard.TargetName="grid"
                                                                                 Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                                 To="1"
                                                                                 d:IsOptimized="True" />

                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="stackpanel" Storyboard.TargetProperty="(UIElement.Visibility)">
                                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                                        <DiscreteObjectKeyFrame.Value>
                                                                            <Visibility>Visible</Visibility>
                                                                        </DiscreteObjectKeyFrame.Value>
                                                                    </DiscreteObjectKeyFrame>
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <VisualStateManager.CustomVisualStateManager>
                                                    <ei:ExtendedVisualStateManager />
                                                </VisualStateManager.CustomVisualStateManager>
                                                <Grid x:Name="grid"
                                                      Background="{StaticResource HighlightBrush}"
                                                      Opacity="0" />
                                                <StackPanel Margin="3" Orientation="Horizontal">
                                                    <TextBlock Width="100" Text="{Binding Code}" />
                                                    <TextBlock>
                                                        <Run Text="{Binding Name}" />
                                                        <Run Text="（" />
                                                        <Run Text="{Binding English}" />
                                                        <Run Text="）" />
                                                    </TextBlock>
                                                    <StackPanel Name="stackpanel"
                                                                Orientation="Horizontal"
                                                                Visibility="Collapsed">
                                                        <Button Margin="12,0"
                                                                Foreground="White"
                                                                Style="{StaticResource EditButtonStyle}">
                                                            <i:Interaction.Triggers>
                                                                <i:EventTrigger EventName="Click">
                                                                    <i:InvokeCommandAction Command="{Binding Path=DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" CommandParameter="{Binding Id}" />
                                                                </i:EventTrigger>
                                                            </i:Interaction.Triggers>
                                                        </Button>
                                                        <Button Foreground="White" Style="{StaticResource DeleteButtonStyle}">
                                                            <i:Interaction.Triggers>
                                                                <i:EventTrigger EventName="Click">
                                                                    <i:InvokeCommandAction Command="{Binding Path=DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" CommandParameter="{Binding Id}" />
                                                                </i:EventTrigger>
                                                            </i:Interaction.Triggers>
                                                        </Button>
                                                    </StackPanel>
                                                </StackPanel>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>
                </toolkit:BusyIndicator>
            </Grid>
            <ListBox Grid.Column="2" ItemsSource="{Binding CitiesCollection}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock>
                            <Run Text="{Binding Code}" />
                            <Run Text=" " />
                            <Run Text="{Binding Name}" />
                            <Run Text="（" />
                            <Run Text="{Binding English}" />
                            <Run Text="）" />
                        </TextBlock>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
        <controls:PromptDialog Title="{Binding Operation,
                                               ConverterParameter=ENTITYOPERATION,
                                               Converter={StaticResource EnumTranslationConverter}}"
                               VerticalContentAlignment="Stretch"
                               CloseCommand="{Binding CancelCommand}"
                               Padding="50"
                               Visibility="{Binding ShowUpdate,
                                                    Converter={StaticResource BooleanToVisibilityConverter}}"
                               WindowHeight="320"
                               WindowWidth="400">
            <Grid Margin="12" HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <StackPanel Width="300">
                    <TextBlock Text="编号" />
                    <TextBox IsReadOnly="True" Text="{Binding UpdateEntity.Code}" />
                    <TextBlock Margin="0,12,0,0" Text="名称" />
                    <TextBox Text="{Binding UpdateEntity.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    <TextBlock Margin="0,12,0,0" Text="英文名" />
                    <TextBox Text="{Binding UpdateEntity.English, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

                </StackPanel>

                <StackPanel Grid.Row="1"
                            HorizontalAlignment="Right"
                            Orientation="Horizontal">
                    <Button Width="60"
                            Margin="12,0"
                            Command="{Binding SubmitCommand}"
                            Content="提交" />
                    <Button Width="60"
                            Command="{Binding CancelCommand}"
                            Content="取消" />
                </StackPanel>
            </Grid>
        </controls:PromptDialog>
    </Grid>
</navigation:PageView>
